import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { listSelectData } from '/@/api/m8/order/m8OperCheck';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('检验单选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 60,
  schemas: [
    {
      label: t('单号'),
      field: 'djNo',
      component: 'Input',
    },
    {
      label: t('送检数'),
      field: 'iqty',
      component: 'Input',
    },
    {
      label: t('机床'),
      field: 'machineId',
      component: 'Input',
    },
    {
      label: t('订单ID'),
      field: 'orderId',
      component: 'Input',
      show: false,
    },
    {
      label: t('图纸ID'),
      field: 'picId',
      component: 'Input',
      show: false,
    },
    {
      label: t('图纸编号'),
      field: 'orderPic.picno',
      component: 'Input',
      show: false,
    },
    {
      label: t('流程ID'),
      field: 'flowId',
      component: 'Input',
      show: false,
    },
    {
      label: t('机床ID'),
      field: 'machineId',
      component: 'Input',
      show: false,
    },
    {
      label: t('状态'),
      field: 'checkStatus',
      component: 'Input',
      show: false,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('订单ID'),
    dataIndex: 'orderId',
    key: 'a.order_id',
    sorter: true,
    width: 130,
    align: 'left',
    ifShow: false,
  },
  {
    title: t('图纸ID'),
    dataIndex: 'picId',
    key: 'a.pic_id',
    sorter: true,
    width: 130,
    align: 'left',
    ifShow: false,
  },
  {
    title: t('流程ID'),
    dataIndex: 'flowId',
    key: 'a.flow_id',
    sorter: true,
    width: 130,
    align: 'left',
    ifShow: false,
  },
  {
    title: t('数铣ID'),
    dataIndex: 'sxId',
    key: 'a.sx_id',
    sorter: true,
    width: 130,
    align: 'left',
    ifShow: false,
  },
  {
    title: t('工序'),
    dataIndex: 'oper.operName',
    key: 'a.oper_code',
    sorter: true,
    width: 80,
    align: 'left',
  },
  {
    title: t('检验数'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 60,
    align: 'center',
  },
  {
    title: t('检验类型'),
    dataIndex: 'checkType',
    key: 'a.check_type',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'm8_check_type',
  },
  {
    title: t('送检人'),
    dataIndex: 'sjManagerName',
    key: 'a.checkor',
    sorter: true,
    width: 60,
    align: 'left',
  },
  {
    title: t('图名'),
    dataIndex: 'orderPic.picname',
    key: 'pic.picname',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('图号'),
    dataIndex: 'orderPic.picno',
    key: 'a.pic_id',
    sorter: true,
    width: 120,
    align: 'left',
  },
  {
    title: t('检验单号'),
    dataIndex: 'djNo',
    key: 'a.dj_no',
    sorter: true,
    width: 130,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('任务'),
    dataIndex: 'taskCode',
    key: 'a.task_code',
    sorter: true,
    width: 120,
    align: 'left',
  },
  {
    title: t('机床'),
    dataIndex: 'machineId',
    key: 'a.machine_id',
    sorter: true,
    width: 60,
    align: 'left',
  },
  {
    title: t('订单号'),
    dataIndex: 'order.ccode',
    key: 'a.order.ccode',
    sorter: true,
    width: 120,
    align: 'left',
  },
  {
    title: t('工序类型'),
    dataIndex: 'operType',
    key: 'a.oper_type',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'm8_oper_type',
  },
  {
    title: t('状态'),
    dataIndex: 'checkStatus',
    key: 'a.check_status',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'm8_dj_status',
  },
];

const tableProps: BasicTableProps = {
  api: listSelectData,
  beforeFetch: (params) => {
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'djNo',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'djNo',
  itemName: 'djNo',
};
